/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author YDZ
 */
import { defHttp } from '/@/utils/http/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { BasicModel, Page } from '../model/baseModel';
import { UploadApiResult } from '../sys/upload';
import { UploadFileParams } from '/#/axios';

const { ctxPath, adminPath } = useGlobSetting();

export interface BasCar extends BasicModel<BasCar> {
  cphm?: string; // 车牌号码
  ppxh?: string; // 品牌型号
  cllx?: string; // 车辆类型
  syxz?: string; // 使用性值
  clsyr?: string; // 车辆所有人
  zws?: number; // 座位数
  mrjsy?: string; // 默认驾驶员
  lxdh?: string; // 联系电话
  clzt?: string; // 车辆状态
  fdjhm?: string; // 发动机号码
  clsbdh?: string; // 车辆识别代号
  xnyqc?: string; // 新能源汽车
  ctys?: string; // 车体颜色
  clpz?: string; // 车辆配置
  hdzrs?: number; // 核定载人数
  zbzl?: number; // 整备质量
  zzl?: number; // 总质量
  bsqxs?: string; // 变速器型式
  fdjpl?: string; // 发动机排量
  yxrj?: number; // 油箱容积
  byzq?: number; // 保养周期
  xsdw?: string; // 销售单位
  gcsj?: string; // 购车时间
  gcjg?: number; // 购车价格
  zcdjrq?: string; // 注册登记日期
  fzrq?: string; // 发证日期
  njrq?: string; // 年检日期
  bxdq?: string; // 保险到期
  xxbz?: number; // 限行标志
  cldaLrry?: string; // 录入人员
}

export const basCarList = (params?: BasCar | any) =>
  defHttp.get<BasCar>({ url: adminPath + '/bas/car/basCar/list', params });

export const basCarListData = (params?: BasCar | any) =>
  defHttp.post<Page<BasCar>>({ url: adminPath + '/bas/car/basCar/listData', params });

export const basCarForm = (params?: BasCar | any) =>
  defHttp.get<BasCar>({ url: adminPath + '/bas/car/basCar/form', params });

export const basCarSave = (params?: any, data?: BasCar | any) =>
  defHttp.postJson<BasCar>({ url: adminPath + '/bas/car/basCar/save', params, data });

export const basCarImportData = (
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void,
) =>
  defHttp.uploadFile<UploadApiResult>(
    {
      url: ctxPath + adminPath + '/bas/car/basCar/importData',
      onUploadProgress,
    },
    params,
  );

export const basCarDisable = (params?: BasCar | any) =>
  defHttp.get<BasCar>({ url: adminPath + '/bas/car/basCar/disable', params });

export const basCarEnable = (params?: BasCar | any) =>
  defHttp.get<BasCar>({ url: adminPath + '/bas/car/basCar/enable', params });

export const basCarDelete = (params?: BasCar | any) =>
  defHttp.get<BasCar>({ url: adminPath + '/bas/car/basCar/delete', params });

// 修改车辆状态
export const basCarUpdateStatus = (params?: BasCar | any) =>
  defHttp.get<BasCar>({ url: adminPath + '/bas/car/basCar/updateCarStatus', params });

// 变更驾驶员
export const basCarUpdateDriver = (params?: BasCar | any) =>
  defHttp.get<BasCar>({ url: adminPath + '/bas/car/basCar/updateDriver', params });

// 验证车牌号
export const checkCarNo = (carNo: string) =>
  defHttp.get<BasCar>({
    url: adminPath + '/bas/car/basCar/checkCarNo',
    params: { carNo },
  });
